import request from "@/utils/request";
import type {
  SaveOrUpdateAttrParams,
  GetAttrListParams,
  GetAttrListResponse,
} from "./model/attrmodel";
enum Api {
  getAttrListUrl = `/admin/product/attrInfoList`,
  getAddAttrListUrl = "/admin/product/saveAttrInfo",
  getDeleteAttrUrl = `/admin/product/deleteAttr`,
}
export const getAttrListApi = ({
  category1Id,
  category2Id,
  category3Id,
}: GetAttrListParams) => {
  return request.get<any, GetAttrListResponse>(
    `${Api.getAttrListUrl}/${category1Id}/${category2Id}/${category3Id}`
  );
};
// 添加属性
export const getAddAttrListApi = (data: SaveOrUpdateAttrParams) => {
  return request.post<any, null>(Api.getAddAttrListUrl, data);
};
// 删除属性
export const getDeleteAttrListApi = (id: number) => {
  return request.delete<any, null>(Api.getDeleteAttrUrl + `/${id}`);
};
